<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  </head>

  <body>
    <script>
      /* 
      Promise语法
      */
      let flag = true;
      let p = new Promise((resolve, reject) => {
        // resolve 成功的回调  reject 失败的回调
        if (flag) {
          resolve("卖一斤茶叶");
        } else {
          reject("退出茶艺圈");
        }
      })

      p.then(data => { // 成功的业务逻辑
        console.log("我要" + data);
      }).catch(error => { // 失败的业务逻辑
        console.log("我要" + error);
      })
    </script>
  </body>

</html>